Concurrent processing is a common processing method in various business application systems. For example, highly concurrent transactions in a financial system, such as account processing, involve bookkeeping of payments made from one account to multiple accounts at the same time, or payments collected from multiple accounts to a single account at the same time.
In a typical bookkeeping process in trading, resource locks are first placed on accounts related to the trading (which may include a payment account of a buyer and a recipient account of a seller) to ensure that accuracy of data is not affected by other requests. Bookkeeping of the buyer's account, including voucher recording and balance update, is then performed, and followed by bookkeeping of the seller's account which also includes voucher recording and balance update. After the event of bookkeeping request is completely processed, the resource locks on the buyer's account and the seller's account are both released.
Generally, relevant accounts are required to be locked in each bookkeeping operation in order to avoid other operations from further operating on a currently processed account to cause data inconsistency. As volume of business continues to increase, certain accounts may have multiple concurrent operations in an instant period of time. However, only one thread out of all concurrency threads can possess a resource lock at a time, while other threads are required to wait until the lock is released to conduct bookkeeping accordingly. Under these circumstances, performance of a billing system is severely affected.
For example, if a thousand lottery players make payments to a lottery account at the same time, the events would cause approximately a thousand requests in a queue of the lottery account at that moment. If every request has to wait for its turn to obtain a locking right to be processed, business may be severely affected.
The problem of multiple requests demanding to occupy a same resource at the same time also exists in concurrent processing of other business systems to greatly affect the business efficiency.